var quyu=""
Jurisdictions()
function Jurisdictions(){
    var userid=JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID
    $.ajax({
        type: "get",
        url:''+root.publics.getInfo+'/'+userid+'',
        dataType: "json",
        async:false,//优先运行
        data: {
        },
        //传入组装的参数
        success: function (data) {
            if(data.errorCode=="0") {
                console.log(data)
                //区域内容
                if(data.data.sysUserAreas!=null){
                    var dataInter=data.data.sysUserAreas;
                    var integralValues=[]
                    for (var i = 0; i < dataInter.length; i++)
                    {
                        integralValues.push(dataInter[i].warehouseCode)/*[i].warehouseCode*/;   //调用数组的push方法将数据添加到数组中
                        quyu=integralValues
                    }
                    quyu=integralValues//用于下拉框
                    var region= integralValues.join(",")
                    sessionStorage.setItem("regiona",region);

                    var integralValues4=[]
                    for (var i = 0; i < dataInter.length; i++)
                    {
                        integralValues4.push(dataInter[i].areaId)/*[i].warehouseCode*/;   //调用数组的push方法将数据添加到数组中
                    }
                    var areaId= integralValues4.join(",")
                    sessionStorage.setItem("areaId",areaId);
                }else {
                    sessionStorage.setItem("regiona","");
                    sessionStorage.setItem("areaId","");
                }

                //公司内容
                var dataInter2=data.data.sysUserOrganizations;
                console.log(dataInter2)
                var integralValues2=[]
                for (var i = 0; i < dataInter2.length; i++)
                {
                    integralValues2.push(dataInter2[i].organizationId);   //调用数组的push方法将数据添加到数组中
                }

                var company= integralValues2.join(",")
                sessionStorage.setItem("companya",company);

                //人员内容
                var dataInter3=data.data.sysUserSalesSupervisors;
                var integralValues3=[]
                for (var i = 0; i < dataInter3.length; i++)
                {
                    integralValues3.push(dataInter3[i].salesSupervisorUserId);   //调用数组的push方法将数据添加到数组中
                }
                var personnel= integralValues3.join(",")
                sessionStorage.setItem("personnela",personnel);


            }
        }
    })
}

//订单专用权限
orderJurisdiction()
function orderJurisdiction(){
    var userid=JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID
    $.ajax({
        type: "get",
        url:''+root.publics.getInfoByOrder+'/'+userid+'',
        dataType: "json",
        async:false,//优先运行
        data: {
        },
        //传入组装的参数
        success: function (data) {
            if(data.errorCode=="0") {
                //区域内容
                if(data.data.warehouse!=null && data.data.warehouse!=""){
                    var dataInter=data.data.warehouse;
                    var integralValues=[]
                    for (var i = 0; i < dataInter.length; i++)
                    {
                        if(dataInter[i]!=""){
                            integralValues.push(dataInter[i])/*[i].warehouseCode*/;   //调用数组的push方法将数据添加到数组中
                        }

                    }
                    var region= integralValues.join(",")
                    sessionStorage.setItem("regions",region);
                    var integralValues4=[]
                    for (var i = 0; i < dataInter.length; i++)
                    {
                        integralValues4.push(dataInter[i]);   //调用数组的push方法将数据添加到数组中
                    }

                }else {
                    sessionStorage.setItem("regions","");

                }
                //区域内容
                if(data.data.organizationWarehouse!=null && data.data.organizationWarehouse!=""){
                    var dataInter1=data.data.organizationWarehouse;
                    var integralValues1=[]
                    for (var i = 0; i < dataInter1.length; i++)
                    {
                        integralValues1.push(dataInter1[i])/*[i].warehouseCode*/;   //调用数组的push方法将数据添加到数组中

                    }
                    var region1= integralValues1.join(",")
                    sessionStorage.setItem("organizationWarehouse",region1);


                }else {
                    sessionStorage.setItem("organizationWarehouse","");

                }

                //公司内容
                var dataInter2=data.data.organization;
                console.log(dataInter2)
                var integralValues2=[]
                for (var i = 0; i < dataInter2.length; i++)
                {
                    integralValues2.push(dataInter2[i]);   //调用数组的push方法将数据添加到数组中
                }

                var company= integralValues2.join(",")
                sessionStorage.setItem("companys",company);

                //人员内容
                var dataInter3=data.data.salesSupervisor;
                var integralValues3=[]
                for (var i = 0; i < dataInter3.length; i++)
                {
                    integralValues3.push(dataInter3[i]);   //调用数组的push方法将数据添加到数组中
                }
                var personnel= integralValues3.join(",")
                sessionStorage.setItem("personnels",personnel);


            }
        }
    })
}




//动态发货仓
getAllWare()
function getAllWare(){ //获取所有发货仓
    var sel =document.getElementById("shippingWarehouse");

    $.ajax({
        url: root.publics.getAllWarehouse,
        cache: false, //禁用缓存
        type: "POST",
        dataType:"json",
        success: function(obj){
                for(var i=0;i<obj.data.length;i++){
                        if(sel != null){
                                var option = new Option(obj.data[i].warehouse_name,obj.data[i].warehouse_code);
                                sel.options.add(option) 
                }
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log(XMLHttpRequest);
        }
    });

};
getAllWareno();
function getAllWareno(){
    var selno = document.getElementById("shippingWarehouseno");
    $.ajax({
        url: root.publics.getAllWarehouse,
        cache: false, //禁用缓存
        type: "POST",
        dataType:"json",
        success: function(obj){

                for(var i=0;i<obj.data.length;i++){
                        if(selno != null){
                                if(obj.data[i].warehouse_data_type != 2 ){
                                    var option = new Option(obj.data[i].warehouse_name,obj.data[i].warehouse_code);
                                    selno.options.add(option)
                                }
                        }
                }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log(XMLHttpRequest);
        }
    });
}



